/*
* @File Name fast_math.c
* @File Path M:\MAS2\PRM_Robotic_Arm\PRMCcode\coding\math\fast_math.c
* @Author: Ruige_Lee
* @Date:   2019-08-19 21:15:42
* @Last Modified by:   Ruige_Lee
* @Last Modified time: 2019-09-01 16:28:55
* @Email: 295054118@whut.edu.cn
* @page: https://whutddk.github.io/
*/

#include <stdint.h>

# if 1

#include <math.h>
int32_t IsEqual(float dat0, float dat1)
{
	if ( ((dat0 - dat1) < 0.001)
		&&
		((dat0 - dat1) > -0.001)
		 )
	{
		return 1;
	}
	
	else
	{
		return 0;
	}
}

float fast_sin(float angle)
{
	return (float)(sin(angle));
}

float fast_cos(float angle)
{
	return (float)(cos(angle));
}


float fast_abs(float data)
{
	if ( data > 0.0000 )
	{
		return data;
	}
	else
	{
		return -data;
	}
}


uint32_t fast_power( uint32_t data, uint32_t power )
{
	uint32_t result = 1;
	for ( uint32_t i = 0; i < power; i++ )
	{
		result *= data;
	}
	return result;
}

float fast_max(float A, float B)
{
	if ( A > B )
	{
		return A;
	}
	else
	{
		return B;
	}
}

#endif


